<template>
  <div>
    <input v-model="newTodoText" placeholder="输入新的待办事项" />
    <button @click="addNewTodo">添加</button>
  </div>
</template>

<script setup>
import { ref, defineEmits } from 'vue';

const newTodoText = ref('');
const emits = defineEmits(['add-todo']);

const addNewTodo = () => {
  if (newTodoText.value.trim()) {
    emits('add-todo', newTodoText.value.trim());
    newTodoText.value = '';
  }
};
</script>

<style scoped>
input {
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  margin-right: 10px;
}

button {
  padding: 8px 16px;
  background-color: #007BFF;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

button:hover {
  background-color: #0056b3;
}
</style>